package com.rd.student.ruanjian.class3.gaochenxi.NumberSix;

import java.util.Collections;
import java.util.LinkedList;

public class NumberSix {
      public static void main(String[] args) {
            LinkedList list = new LinkedList();

            Student stu = new Student("liusan", 20, 90);
            Student stu1 = new Student("lisi", 22, 90);
            Student stu2 = new Student("wangwu", 20, 99);
            Student stu3 = new Student("sunliu", 22, 100);

            list.add(stu);
            list.add(stu1);
            list.add(stu2);
            list.add(stu3);

            Collections.sort(list);

            System.out.print(list+"  ");
      }

}

class Student implements Comparable {

      private String name;

      private int age;

      private int score;



      public Student() {

      }

      public Student(String name, int age, int score) {
            this.name = name;
            this.age = age;
            this.score = score;
      }

      public String getName() {
            return name;
      }

      public void setName(String name) {
            this.name = name;
      }

      public int getAge() {
            return age;
      }

      public void setAge(int age) {
            this.age = age;
      }

      public int getScore() {
            return score;
      }

      public void setScore(int score) {
            this.score = score;
      }

      @Override
      public String toString() {
            return "[" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", score=" + score +
                    ']';
      }

      @Override
      public int compareTo(Object o) {

           Student stu = (Student) o;

           if(stu.score>this.score){
                 return 1;

           } else if (this.score> stu.score) {
                 return -1;
           }
            return 0;
      }
}
